package com.yoda.mall.admin.service;

import com.yoda.mall.admin.intercepter.ThreadContext;
import com.yoda.mall.api.OrderApi;
import com.yoda.mall.model.entity.oms.Order;
import com.yoda.mall.model.vo.OrderDetailVo;
import com.yoda.mall.model.vo.PageResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.util.List;

/**
 * @author wjy
 * @date 2022年 12月 18日 15:34
 */
@Service
public class OrderService {
    @DubboReference
    private OrderApi orderApi;

    /**
     * 批量删除兼单个删除
     *
     * @param ids
     */
    public void orderDle(List<Integer> ids) {
        orderApi.deletes(ids);

    }

    /**
     * 查询订单
     *
     * @param pageNum
     * @param pageSize
     * @param createTime
     * @param orderType
     * @param orderSn
     * @param sourceType
     * @param status
     * @return
     */
    public PageResult<Order> orderList(Integer pageNum, Integer pageSize, String createTime, Integer orderType, String orderSn, Integer sourceType, Integer status,String receiverKeyword) throws ParseException {

        return orderApi.orderList(pageNum,pageSize,createTime,orderType,orderSn,sourceType,status,receiverKeyword);

    }

    /**
     *批量关闭
     * @param ids
     * @param note
     */
    public void updateClose(List<Long> ids, String note) {
        String username = ThreadContext.getUsername();
        orderApi.updateClose(ids, note,username);
    }

    public Integer updateDelivery(List<Order> orders) {
        String username = ThreadContext.getUsername();
        return orderApi.updateDelivery(orders,username);
    }
    public OrderDetailVo getOrderDetailById(Long id) {
        return orderApi.getOrderDetailById(id);
    }

    public Integer updateOrderById(Order order) {
        String username = ThreadContext.getUsername();
        return orderApi.updateOrderById(order,username);
    }
}
